using MicroMsg.Common.Utils;
using Microsoft.Xna.Framework.Media;
using System;
using System.Collections.Generic;
using System.Xml.Linq;
namespace MicroMsg.Storage
{
	public class TloMedia : TloXmlItem
	{
		private const string TAG = "TimeLineObject";
		public ulong nID;
		public int nType;
		public string strTitle;
		public string strDescription;
		public int nPrivate;
		public int nUrlType;
		public string strUrl;
		public int nThumbType;
		public string strThumb;
		public float nWidth;
		public float nHeight;
		public float nTotalSize;
		public Picture mPicture;
		public int nAngle;
		public TloMedia()
		{
		}
		public TloMedia(XElement xelement_0)
		{
			this.parse(xelement_0);
		}
		public bool parse(XElement xelement_0)
		{
			using (IEnumerator<XElement> enumerator = xelement_0.Elements().GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					XElement current = enumerator.get_Current();
					if (!current.get_IsEmpty() || current.get_HasAttributes())
					{
						if (current.get_Name() == "id")
						{
							this.nID = (ulong)current;
						}
						else
						{
							if (current.get_Name() == "type")
							{
								this.nType = (int)current;
							}
							else
							{
								if (current.get_Name() == "title")
								{
									this.strTitle = (string)current;
								}
								else
								{
									if (current.get_Name() == "description")
									{
										this.strDescription = (string)current;
									}
									else
									{
										if (current.get_Name() == "private")
										{
											this.nPrivate = (int)current;
										}
										else
										{
											if (current.get_Name() == "url")
											{
												this.strUrl = (string)current;
												this.nUrlType = (int)current.Attribute("type");
											}
											else
											{
												if (current.get_Name() == "thumb")
												{
													this.strThumb = (string)current;
													this.nThumbType = (int)current.Attribute("type");
												}
												else
												{
													if (current.get_Name() == "size")
													{
														using (IEnumerator<XAttribute> enumerator2 = current.Attributes().GetEnumerator())
														{
															while (enumerator2.MoveNext())
															{
																XAttribute current2 = enumerator2.get_Current();
																if (current2.get_Name() == "width")
																{
																	this.nWidth = (float)current.Attribute("width");
																}
																else
																{
																	if (current2.get_Name() == "height")
																	{
																		this.nHeight = (float)current.Attribute("height");
																	}
																	else
																	{
																		if (current2.get_Name() == "nTotalSize")
																		{
																			this.nTotalSize = (float)current.Attribute("totalSize");
																		}
																	}
																}
															}
															continue;
														}
													}
													Log.smethod_4("TimeLineObject", "unknown constent object tag=" + current.get_Name());
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
			return true;
		}
		public XElement toXElement()
		{
			XElement xElement = new XElement("media");
			xElement.Add(new XElement("id", this.nID));
			xElement.Add(new XElement("type", this.nType));
			if (this.strTitle != null)
			{
				xElement.Add(new XElement("title", this.strTitle));
			}
			if (this.strDescription != null)
			{
				xElement.Add(new XElement("description", this.strDescription));
			}
			xElement.Add(new XElement("private", this.nPrivate));
			xElement.Add(new XElement("url", new object[]
			{
				new XAttribute("type", this.nUrlType),
				this.strUrl
			}));
			xElement.Add(new XElement("thumb", new object[]
			{
				new XAttribute("type", this.nThumbType),
				this.strThumb
			}));
			xElement.Add(new XElement("size", new object[]
			{
				new XAttribute("width", this.nWidth),
				new XAttribute("height", this.nHeight),
				new XAttribute("totalSize", this.nTotalSize)
			}));
			return xElement;
		}
	}
}
